#ifndef LZWENCODER_H
#define LZWENCODER_H

#include <QIODevice>
#include <QObject>

namespace WingGif {

class LZWEncoder : public QObject {
  Q_OBJECT

  Q_PROPERTY(int colorDepth READ colorDepth WRITE setColorDepth)
  Q_PROPERTY(QByteArray indexedPixels READ indexedPixels WRITE setIndexedPixels)

public:
  explicit LZWEncoder(QByteArray indexedPixel, int colorDepth,
                      QObject *parent = nullptr);

  int colorDepth();
  void setColorDepth(int value);

  QByteArray indexedPixels();
  void setIndexedPixels(QByteArray value);

  void encode(QIODevice *internalStream);

protected:
  const int MaxStackSize = 4096;
  // Under GIF encoding up to 12bit, the maximum value is 4096

  char Nullcode = 0;

private:
  int _colorDepth;
  QByteArray _indexedPixels;
  int initDataSize;
};

} // namespace WingGif

#endif // LZWENCODER_H
